<template>
  <!-- 典当行 -->
  <view class="root">
    <view class="top">
      <uni-easyinput prefixIcon="search" v-model="searchValue" placeholder="请填写关键字搜索" @input="input"
        class="search-input"></uni-easyinput>
    </view>
    <view class="content">
      <yy-scroll-view ref="scrllViewRef" request-url="/industry/wasteRecyclingRecordList" :auto-request="false"
        :static-params="staticParams">
        <template slot-scope="{list}">
          <view class="list-item-wrapper" v-for="(item, index) in list" :key="index" @click="handleDetail(item.id)">
            <view class="list-item-title">
              {{item.wasteName}}
            </view>
            <view class="list-item">
              <view class="list-label">
                上报时间:
              </view>
              <view class="list-value">
                {{item.createTime}}
              </view>
            </view>
          </view>
        </template>
      </yy-scroll-view>
    </view>
    <view class="bottom">
      <yy-button-add @click="handleAdd" text="新增可疑物品"></yy-button-add>
    </view>
  </view>
</template>

<script>
  import {
    navTo,
  } from '@/utils/util.js'


  export default {
    data() {
      return {
        scrllViewRef: null,
        searchValue: '',
        inputStyles: {
          background: '#f8f8f8',
          borderRadius: '340rpx 340rpx 340rpx 340rpx',
          border: '1rpx solid #F1F2F3',
        },
        options: {},
        staticParams: {}
      }
    },
    onLoad(options) {
      this.options = options
      // 获取列表数据
      // 获取列表数据
      Object.assign(this.staticParams, {
        companyId: this.options.companyMessageId
      })
      this.$refs.scrllViewRef.getList('init', this.staticParams)
      uni.$on('junk-list-add', () => {
        this.staticParams.likeName = ''
        this.$refs.scrllViewRef.getList('init', this.staticParams)
      })
    },
    onUnload() {
      uni.$off('junk-list-add')
    },
    methods: {
      input(val) {
        Object.assign(this.staticParams, {
          likeName: this.searchValue ? this.searchValue.trim() : '',
        })
        this.$refs.scrllViewRef.getList('init', this.staticParams)
      },
      handleAdd() {
        navTo({
          url: '/featuredIndustries/junkList/junkListAdd',
          params: {
            companyMessageId: this.options.companyMessageId
          }
        })
      },
      handleDetail(id) {
        navTo({
          url: '/featuredIndustries/junkList/junkListDetail',
          params: {
            id
          }
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .root {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    background: #F9F9F9;


    .top {
      padding: 25rpx;
      background: #FFFFFF;

      /deep/ .is-input-border {
        background: #F8F8F8 !important;
        border-radius: 340rpx 340rpx 340rpx 340rpx !important;
        border: 1rpx solid #F1F2F3 !important;
      }
    }

    .content {
      flex: 1;
      padding: 10rpx 15rpx;
      height: 0;
    }

    .list-item-wrapper {
      padding: 32rpx;
      background: #FFFFFF;
      border-radius: 16rpx 16rpx 16rpx 16rpx;
      margin-bottom: 14rpx;

      .list-item-title {
        font-weight: bold;
        font-size: 30rpx;
        color: #181818;
      }

      .list-item {
        display: flex;
        margin-top: 18rpx;

        .list-label {
          font-weight: 500;
          font-size: 28rpx;
          color: #999999;
          margin-right: 5rpx;
          flex-shrink: 0;
        }

        .list-value {
          font-weight: 500;
          font-size: 28rpx;
          color: #101010;
        }
      }
    }

    .bottom {}
  }
</style>